package com.qzsoft.zhjd.materiel.modules.materieltareanalysis.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.qzsoft.zhjd.materiel.modules.materieldata.dto.MaterielDataListDto;
import com.qzsoft.zhjd.materiel.modules.materieltareanalysis.dto.MaterielTareChartDto;
import com.qzsoft.zhjd.materiel.modules.materieltareanalysis.dto.MaterielTareListDto;
import com.qzsoft.zhjd.materiel.modules.materieltareanalysis.service.MaterielTareAnalysisService;

/**
 * @ClassName MaterielTareAnalysisController
 * @Description 车辆皮重控制器
 * @author linhuawei
 * @since 2022-04-01
 */
@RestController
@RequestMapping("/api/materielTareAnalysis")
public class MaterielTareAnalysisController {

    @Autowired
    private MaterielTareAnalysisService materielTareAnalysisService;

    /**
     * @Title page
     * @Description 车辆皮重分页列表
     * @param params 查询条件
     * @return 车辆皮重分页列表
     */
    @RequiresPermissions("materiel:tareanalysis")
    @GetMapping("/page")
    public Result<IPage<MaterielTareListDto>> page(@RequestParam Map<String, Object> params) {
        IPage<MaterielTareListDto> page = materielTareAnalysisService.page(params);
        return ResultUtils.ok(page);
    }

    /**
     * @Title pageForCar
     * @Description 获取当前车辆磅单分页列表
     * @param carNumber 车牌号
     * @return 当前车辆磅单分页列表
     */
    @RequiresPermissions("materiel:tareanalysis")
    @GetMapping("/pageForCar")
    public Result<IPage<MaterielDataListDto>> pageForCar(@RequestParam Map<String, Object> params) {
        IPage<MaterielDataListDto> page = materielTareAnalysisService.pageForCar(params);
        return ResultUtils.ok(page);
    }

    /**
     * @Title chartForCar
     * @Description 获取车辆图表
     * @param carNumber 车牌号
     * @return 车辆图表
     */
    @RequiresPermissions("materiel:tareanalysis")
    @GetMapping("/chartForCar")
    public Result<List<MaterielTareChartDto>> chartForCar(@RequestParam(required = true) String carNumber) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("carNumber", carNumber);
        List<MaterielTareChartDto> data = materielTareAnalysisService.chartForCar(params);
        return ResultUtils.ok(data);
    }
}
